<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">
        <input type="text" v-model.lazy='msg'>
        <span>{{show}}</span>
    </div>
    <script src="./js/vue.js"></script>
    <script>
        const ve = new Vue({
            el:'#app',
            data:{
                msg:'',
                show:''
            },
            methods:{
                change(msg) {
                    var that = this
                   setTimeout(()=>{
                       if(that.msg==='admin') {
                           that.show='用户名以重复'
                           console.log(msg);
                       } else {
                           that.show='用户名注册成功'
                           console.log(msg);
                       }
                   },2000)
                }
            },
            watch:{
                msg(val) {
                    this.change(val)
                    this.show='用户名注册中.....'
                }
            }
        })
    </script>
</body>
</html>